import useAxiosApi from '/@/utils/useAxiosApi';

const baseUrl = import.meta.env.VITE_APP_EDU_API;
let firstIn = false
let logoUrlProduct = ''
let logoUrlLocal = '/jwfilepath/wxLogo/favicon.png'

/**
 * 账号密码登录
 * @returns UseAxiosReturn
 */
export function loginPassword() {
    return useAxiosApi(baseUrl + `/login`, {
        method: 'POST',
        data: {name: '123'},
    });
}

/**
 * 获取用户信息
 * @returns UseAxiosReturn
 */
export function getUserInfo01(userId) {
    return useAxiosApi(baseUrl + '/sport.ryidLogin', {
        method: 'POST',
        data: {ryid: userId},
    });
}

/**
 * 获取用户信息
 * @returns UseAxiosReturn
 */
export function getUserInfo(userId) {
    return useAxiosApi(baseUrl + '/sport.tokenLogin', {
        method: 'POST',
        data: {
            account: userId,
            sys: "edu"
        },
    });
}

export function getUserByCode(code) {
    return useAxiosApi(baseUrl + '/LoginBycode', {
        method: 'POST',
        data: {
            code: code,
        },
    });
}

export function getUserByBD(name, pwd) {
    return useAxiosApi(baseUrl + '/LoginBD', {
        method: 'POST',
        data: {
            username: name,
            password: pwd,
            type: "BD"
        },
    });
}

export function getUserByTY(name, pwd) {
    return useAxiosApi(baseUrl + '/LoginBD', {
        method: 'POST',
        data: {
            username: name,
            password: pwd,
            type: "TY"
        },
    });
}

export function logoutByOpenid() {
    return useAxiosApi(baseUrl + '/logoutByOpenid', {
        method: 'GET',
    });
}

export function getEduUrl() {
    return import.meta.env.VITE_APP_EDU_URL;
}

export function getLogoUrl() {
    console.log(import.meta.env.VITE_APP_ENV);
    if (import.meta.env.PROD) { /*生产环境*/      /*import.meta.env.VITE_APP_ENV === 'production'*/
        if (logoUrlProduct === '') {
            const url = window.location.host
            logoUrlProduct = window.location.protocol + '//' + window.location.host + logoUrlLocal;
        }
        return logoUrlProduct;
    } else {
        return logoUrlLocal;
    }
}
